#include "Special_Judge.h"
#include "Judge_banner.h"

Special_Judge::Special_Judge() {}

bool Special_Judge::IsSpecial(bool AIfirst,int board[N][N],int I,int J,vector<qz>& m4,vector<qz>& o4,vector<qz>& m3,vector<qz>& o3){
    //转换棋盘
    I++;J++;
    int board1[17][17]={-1};
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            board1[i+1][j+1]=board[i][j];
        }
    }
    if(myfour(AIfirst,board1,I,J)){
        qz temp;
        temp.i=I-1;temp.j=J-1;
        m4.push_back(temp);

        return 1;
    }
    else if(oppfour(AIfirst,board1,I,J)){
        qz temp;
        temp.i=I-1;temp.j=J-1;
        o4.push_back(temp);
        return 1;
    }
    else if(mythree(AIfirst,board1,I,J)){
        qz temp;
        temp.i=I-1;temp.j=J-1;
        m3.push_back(temp);
        return 1;
    }
    else if(oppthree(AIfirst,board1,I,J,board)){
        qz temp;
        temp.i=I-1;temp.j=J-1;
        o3.push_back(temp);
        return 1;
    }
    else return 0;
}

bool Special_Judge::myfour(bool AIfirst,int board[N+2][N+2],int I,int J){
    //1
    //横
    if(J<12){
        if(board[I][J+1]==2&&board[I][J+2]==2&&board[I][J+3]==2&&board[I][J+4]==2){
            return 1;
        }
    }
    //竖
    if(I<12){
        if(board[I+1][J]==2&&board[I+2][J]==2&&board[I+3][J]==2&&board[I+4][J]==2){
            return 1;
        }
    }
    //"\"
    if(I<12&&J<12){
        if(board[I+1][J+1]==2&&board[I+2][J+2]==2&&board[I+3][J+3]==2&&board[I+4][J+4]==2){
            return 1;
        }
    }
    //"/"
    if(I<12&&J>4){
        if(board[I+1][J-1]==2&&board[I+2][J-2]==2&&board[I+3][J-3]==2&&board[I+4][J-4]==2){
            return 1;
        }
    }
    //2
    if(J>4){
        if(board[I][J-1]==2&&board[I][J-2]==2&&board[I][J-3]==2&&board[I][J-4]==2){
            return 1;
        }
    }
    if(I>4){
        if(board[I-1][J]==2&&board[I-2][J]==2&&board[I-3][J]==2&&board[I-4][J]==2){
            return 1;
        }
    }
    if(I>4&&J>4){
        if(board[I-1][J-1]==2&&board[I-2][J-2]==2&&board[I-3][J-3]==2&&board[I-4][J-4]==2){
            return 1;
        }
    }
    if(I>4&&J<12){
        if(board[I-1][J+1]==2&&board[I-2][J+2]==2&&board[I-3][J+3]==2&&board[I-4][J+4]==2){
            return 1;
        }
    }
    //3
    //横
    int number=0;
    for(int j=J-1;j>0;j--){
        if(board[I][j]==2){
            number++;
            continue;
        }
        else break;
    }
    for(int j=J+1;j<16;j++){
        if(board[I][j]==2){
            number++;
            continue;
        }
        else break;
    }
    if(number==4){
        return 1;
    }
    //竖
    number=0;
    for(int i=I-1;i>0;i--){
        if(board[i][J]==2){
            number++;
            continue;
        }
        else break;
    }
    for(int i=I+1;i<16;i++){
        if(board[i][J]==2){
            number++;
            continue;
        }
        else break;
    }
    if(number==4){
        return 1;
    }
    //"\"
    number=0;
    for(int i=I-1,j=J-1;i>0&&j>0;i--,j--){
        if(board[i][j]==2){
            number++;
            continue;
        }
        else break;
    }
    for(int i=I+1,j=J+1;i<16&&j<16;i++,j++){
        if(board[i][j]==2){
            number++;
            continue;
        }
        else break;
    }
    if(number==4){
        return 1;
    }
    //"/"
    number=0;
    for(int i=I-1,j=J+1;i>0&&j<16;i--,j++){
        if(board[i][j]==2){
            number++;
            continue;
        }
        else break;
    }
    for(int i=I+1,j=J-1;i<16&&j>0;i++,j--){
        if(board[i][j]==2){
            number++;
            continue;
        }
        else break;
    }
    if(number==4){
        return 1;
    }
    return 0;
}

bool Special_Judge::oppfour(bool AIfirst,int board[N+2][N+2],int I,int J){
    //连四
    //横向
    if(((J <= 11)&&( board[I][J+1]==1 && board[I][J+2]==1 && board[I][J+3]==1 && board[I][J+4]==1))||((J >= 5)&&( board[I][J-1]==1 && board[I][J-2]==1 && board[I][J-3]==1 && board[I][J-4]==1)))
        return 1;
    //纵向
    else if(((I <= 11)&&( board[I+1][J]==1 && board[I+2][J]==1 && board[I+3][J]==1 && board[I+4][J]==1))||((I >= 5)&&( board[I-1][J]==1 && board[I-2][J]==1 && board[I-3][J]==1 && board[I-4][J]==1)))
        return 1;
    //"\"
    else if((I<=11 && J<=11 && board[I+1][J+1]==1 && board[I+2][J+2]==1 && board[I+3][J+3]==1 && board[I+4][J+4]==1)||(I>=5 && J>=5 && board[I-1][J-1]==1 && board[I-2][J-2]==1 && board[I-3][J-3]==1 && board[I-4][J-4]==1))
        return 1;
    //"/"
    else if((I<=11 && J>=5 && board[I+1][J-1]==1 && board[I+2][J-2]==1 && board[I+3][J-3]==1 && board[I+4][J-4]==1)||(I>=5 && J<=11 && board[I-1][J+1]==1 && board[I-2][J+2]==1 && board[I-3][J+3]==1 && board[I-4][J+4]==1))
        return 1;
    //跳四
    //横向
    if(((J <= 12)&&(J >= 2)&& board[I][J-1]==1 && board[I][J+1]==1 && board[I][J+2]==1 && board[I][J+3]==1 )||((J >= 4)&& (J <= 14) &&( board[I][J-1]==1 && board[I][J-2]==1 && board[I][J-3]==1 && board[I][J+1]==1)))
        return 1;
    //纵向
    else if(((I <= 12)&&(I >= 2)&&board[I-1][J]==1 && board[I+1][J]==1 && board[I+2][J]==1 && board[I+3][J]==1 )||((I >= 4)&& (I <= 14) &&( board[I-1][J]==1 && board[I-2][J]==1 && board[I-3][J]==1 && board[I+1][J] == 1 )))
    {
        return 1;}
    //"\"
    else if((I<=12 && J<=12 && I>=2 && J>=2 && board[I-1][J-1]==1 && board[I+1][J+1]==1 && board[I+2][J+2]==1 && board[I+3][J+3]==1 )||(I>=4 && J>=4 && I<=14 && J<=14 && board[I-1][J-1]==1 && board[I-2][J-2]==1 && board[I-3][J-3]==1 && board[I+1][J+1]==1 ))
        return 1;
    //"/"
    else if((I<=12 && J>=4 && I>=2 && J<=14 && board[I-1][J+1]==1 && board[I+1][J-1]==1 && board[I+2][J-2]==1 && board[I+3][J-3]==1 )||(I>=4 && J<=12 && I<=14 && J>=2 && board[I-1][J+1]==1 && board[I-2][J+2]==1 && board[I-3][J+3]==1 && board[I+1][J-1]==1))
        return 1;
    //跳四 -- --
    //横向
    if(J>=3 && J<=13)
        if( board[I][J-2] == 1 && board[I][J-1] == 1 && board[I][J+1] == 1 && board[I][J+2] == 1 )
            return 1;
    //纵向
    if(I>=3 && I<=13)
        if(board[I-2][J] == 1 && board[I-1][J] == 1 && board[I+1][J] == 1 && board[I+2][J] == 1 )
            return 1;
    //"\"
    if(J>=3 && J<=13 && I>=3 && I<=13)
    {
        if( board[I-2][J-2] == 1 && board[I-1][J-1] == 1 && board[I+1][J+1] == 1 && board[I+2][J+2] == 1 )
            return 1;
        //"/"
        else if(board[I-2][J+2] == 1 && board[I-1][J+1] == 1 && board[I+1][J-1] == 1 && board[I+2][J-2] == 1 )
            return 1;
    }
    return 0;
}

bool Special_Judge::mythree(bool AIfirst,int board[N+2][N+2],int I,int J){
    if(AIfirst==0){
        //1
        if(J>4&&J<15){
            if(board[I][J-4]==0&&board[I][J-3]==2&&board[I][J-2]==2&&board[I][J-1]==2&&board[I][J+1]==0){
                cout<<"qqqqqqqqqqqq  "<<I-1<<" "<<J-1<<endl;
                return 1;
            }
        }
        if(I>4&&I<15){
            if(board[I-4][J]==0&&board[I-3][J]==2&&board[I-2][J]==2&&board[I-1][J]==2&&board[I+1][J]==0){
                return 1;
            }
        }
        if(I>4&&I<15&&J>4&&J<15){
            if(board[I-4][J-4]==0&&board[I-3][J-3]==2&&board[I-2][J-2]==2&&board[I-1][J-1]==2&&board[I+1][J+1]==0){
                return 1;
            }
        }
        if(I>4&&I<15&&J>1&&J<12){
            if(board[I-4][J+4]==0&&board[I-3][J+3]==2&&board[I-2][J+2]==2&&board[I-1][J+1]==2&&board[I+1][J-1]==0){
                return 1;
            }
        }
        //2
        if(J>1&&J<12){
            if(board[I][J-1]==0&&board[I][J+1]==2&&board[I][J+2]==2&&board[I][J+3]==2&&board[I][J+4]==0){
                return 1;
            }
        }
        if(I>1&&I<12){
            if(board[I-1][J]==0&&board[I+1][J]==2&&board[I+2][J]==2&&board[I+3][J]==2&&board[I+4][J]==0){
                return 1;
            }
        }
        if(I>1&&I<12&&J>1&&J<12){
            if(board[I-1][J-1]==0&&board[I+1][J+1]==2&&board[I+2][J+2]==2&&board[I+3][J+3]==2&&board[I+4][J+4]==0){
                return 1;
            }
        }
        if(I>1&&I<12&&J>4&&J<15){
            if(board[I-1][J+1]==0&&board[I+1][J-1]==2&&board[I+2][J-2]==2&&board[I+3][J-3]==2&&board[I+4][J-4]==0){
                return 1;
            }
        }
        //3
        if(J>3&&J<14){
            if(board[I][J-3]==0&&board[I][J-2]==2&&board[I][J-1]==2&&board[I][J+1]==2&&board[I][J+2]==0){
                return 1;
            }
        }
        if(I>3&&I<14){
            if(board[I-3][J]==0&&board[I-2][J]==2&&board[I-1][J]==2&&board[I+1][J]==2&&board[I+2][J]==0){
                return 1;
            }
        }
        if(I>3&&I<14&&J>3&&J<14){
            if(board[I-3][J-3]==0&&board[I-2][J-2]==2&&board[I-1][J-1]==2&&board[I+1][J+1]==2&&board[I+2][J+2]==0){
                return 1;
            }
        }
        if(I>3&&I<14&&J>2&&J<13){
            if(board[I-3][J+3]==0&&board[I-2][J+2]==2&&board[I-1][J+1]==2&&board[I+1][J-1]==2&&board[I+2][J-2]==0){
                return 1;
            }
        }
        //4
        if(J>2&&J<13){
            if(board[I][J-2]==0&&board[I][J-1]==2&&board[I][J+1]==2&&board[I][J+2]==2&&board[I][J+3]==0){
                return 1;
            }
        }
        if(I>2&&I<13){
            if(board[I-2][J]==0&&board[I-1][J]==2&&board[I+1][J]==2&&board[I+2][J]==2&&board[I+3][J]==0){
                return 1;
            }
        }
        if(I>2&&I<13&&J>2&&J<13){
            if(board[I-2][J-2]==0&&board[I-1][J-1]==2&&board[I+1][J+1]==2&&board[I+2][J+2]==2&&board[I+3][J+3]==0){
                return 1;
            }
        }
        if(I>2&&I<13&&J>3&&J<14){
            if(board[I-2][J+2]==0&&board[I-1][J+1]==2&&board[I+1][J-1]==2&&board[I+2][J-2]==2&&board[I+3][J-3]==0){
                return 1;
            }
        }
    }
    else{
        //1
        if(J>4&&J<15){
            if(board[I][J-5]!=2&&board[I][J-4]==0&&board[I][J-3]==2&&board[I][J-2]==2&&board[I][J-1]==2&&board[I][J+1]==0&&board[I][J+2]!=2){
                return 1;
            }
        }
        if(I>4&&I<15){
            if(board[I-5][J]!=2&&board[I-4][J]==0&&board[I-3][J]==2&&board[I-2][J]==2&&board[I-1][J]==2&&board[I+1][J]==0&&board[I+2][J]!=2){
                return 1;
            }
        }
        if(I>4&&I<15&&J>4&&J<15){
            if(board[I-5][J-5]!=2&&board[I-4][J-4]==0&&board[I-3][J-3]==2&&board[I-2][J-2]==2&&board[I-1][J-1]==2&&board[I+1][J+1]==0&&board[I+2][J+2]!=2){
                return 1;
            }
        }
        if(I>4&&I<15&&J>1&&J<12){
            if(board[I-5][J+5]!=2&&board[I-4][J+4]==0&&board[I-3][J+3]==2&&board[I-2][J+2]==2&&board[I-1][J+1]==2&&board[I+1][J-1]==0&&board[I+2][J-2]!=2){
                return 1;
            }
        }
        //2
        if(J>1&&J<12){
            if(board[I][J-2]!=2&&board[I][J-1]==0&&board[I][J+1]==2&&board[I][J+2]==2&&board[I][J+3]==2&&board[I][J+4]==0&&board[I][J+5]!=2){
                return 1;
            }
        }
        if(I>1&&I<12){
            if(board[I-2][J]!=2&&board[I-1][J]==0&&board[I+1][J]==2&&board[I+2][J]==2&&board[I+3][J]==2&&board[I+4][J]==0&&board[I+5][J]!=2){
                return 1;
            }
        }
        if(J>1&&J<12&&I>1&&I<12){
            if(board[I-2][J-2]!=2&&board[I-1][J-1]==0&&board[I+1][J+1]==2&&board[I+2][J+2]==2&&board[I+3][J+3]==2&&board[I+4][J+4]==0&&board[I+5][J+5]!=2){
                return 1;
            }
        }
        if(I>1&&I<12&&J>4&&J<15){
            if(board[I-2][J+2]!=2&&board[I-1][J+1]==0&&board[I+1][J-1]==2&&board[I+2][J-2]==2&&board[I+3][J-3]==2&&board[I+4][J-4]==0&&board[I+5][J-5]!=2){
                return 1;
            }
        }
        //3
        if(J>2&&J<13){
            if(board[I][J-3]!=2&&board[I][J-2]==0&&board[I][J-1]==2&&board[I][J+1]==2&&board[I][J+2]==2&&board[I][J+3]==0&&board[I][J+4]!=2){
                return 1;
            }
        }
        if(I>2&&I<13){
            if(board[I-3][J]!=2&&board[I-2][J]==0&&board[I-1][J]==2&&board[I+1][J]==2&&board[I+2][J]==2&&board[I+3][J]==0&&board[I+4][J]!=2){
                return 1;
            }
        }
        if(I>2&&I<13&&J>2&&J<13){
            if(board[I-3][J-3]!=2&&board[I-2][J-2]==0&&board[I-1][J-1]==2&&board[I+1][J+1]==2&&board[I+2][J+2]==2&&board[I+3][J+3]==0&&board[I+4][J+4]!=2){
                return 1;
            }
        }
        if(I>2&&I<13&&J>3&&J<14){
            if(board[I-3][J+3]!=2&&board[I-2][J+2]==0&&board[I-1][J+1]==2&&board[I+1][J-1]==2&&board[I+2][J-2]==2&&board[I+3][J-3]==0&&board[I+4][J-4]!=2){
                return 1;
            }
        }
        //4
        if(J>3&&J<14){
            if(board[I][J-4]!=2&&board[I][J-3]==0&&board[I][J-2]==2&&board[I][J-1]==2&&board[I][J+1]==2&&board[I][J+2]==0&&board[I][J+3]!=2){
                return 1;
            }
        }
        if(I>3&&I<14){
            if(board[I-4][J]!=2&&board[I-3][J]==0&&board[I-2][J]==2&&board[I-1][J]==2&&board[I+1][J]==2&&board[I+2][J]==0&&board[I+3][J]!=2){
                return 1;
            }
        }
        if(I>3&&I<14&&J>3&&J<14){
            if(board[I-4][J-4]!=2&&board[I-3][J-3]==0&&board[I-2][J-2]==2&&board[I-1][J-1]==2&&board[I+1][J+1]==2&&board[I+2][J+2]==0&&board[I+3][J+3]!=2){
                return 1;
            }
        }
        if(I>3&&I<14&&J>2&&J<13){
            if(board[I-4][J+4]!=2&&board[I-3][J+3]==0&&board[I-2][J+2]==2&&board[I-1][J+1]==2&&board[I+1][J-1]==2&&board[I+2][J-2]==0&&board[I+3][J-3]!=2){
                return 1;
            }
        }
    }
    return 0;
}

bool Special_Judge::oppthree(bool AIfirst,int board[N+2][N+2],int I,int J,int board0[N][N]){
    if(AIfirst==1){
        //1
        if(J<12){
            if(board[I][J+1]==1&&board[I][J+2]==1&&board[I][J+3]==1&&board[I][J+4]==0){
                return 1;
            }
        }
        if(I<12){
            if(board[I+1][J]==1&&board[I+2][J]==1&&board[I+3][J]==1&&board[I+4][J]==0){
                return 1;
            }
        }
        if(I<12&&J<12){
            if(board[I+1][J+1]==1&&board[I+2][J+2]==1&&board[I+3][J+3]==1&&board[I+4][J+4]==0){
                return 1;
            }
        }
        if(I<12&&J>4){
            if(board[I+1][J-1]==1&&board[I+2][J-2]==1&&board[I+3][J-3]==1&&board[I+4][J-4]==0){
                return 1;
            }
        }
        //2
        if(J>4){
            if(board[I][J-1]==1&&board[I][J-2]==1&&board[I][J-3]==1&&board[I][J-4]==0){
                return 1;
            }
        }
        if(I>4){
            if(board[I-1][J]==1&&board[I-2][J]==1&&board[I-3][J]==1&&board[I-4][J]==0){
                return 1;
            }
        }
        if(I>4&&J>4){
            if(board[I-1][J-1]==1&&board[I-2][J-2]==1&&board[I-3][J-3]==1&&board[I-4][J-4]==0){
                return 1;
            }
        }
        if(I>4&&J<12){
            if(board[I-1][J+1]==1&&board[I-2][J+2]==1&&board[I-3][J+3]==1&&board[I-4][J+4]==0){
                return 1;
            }
        }
        //3
        if(J>3&&J<14){
            if(board[I][J-3]==0&&board[I][J-2]==1&&board[I][J-1]==1&&board[I][J+1]==1&&board[I][J+2]==0){
                return 1;
            }
        }
        if(I>3&&I<14){
            if(board[I-3][J]==0&&board[I-2][J]==1&&board[I-1][J]==1&&board[I+1][J]==1&&board[I+2][J]==0){
                return 1;
            }
        }
        if(I>3&&I<14&&J>3&&J<14){
            if(board[I-3][J-3]==0&&board[I-2][J-2]==1&&board[I-1][J-1]==1&&board[I+1][J+1]==1&&board[I+2][J+2]==0){
                return 1;
            }
        }
        if(I>3&&I<14&&J>2&&J<13){
            if(board[I-3][J+3]==0&&board[I-2][J+2]==1&&board[I-1][J+1]==1&&board[I+1][J-1]==1&&board[I+2][J-2]==0){
                return 1;
            }
        }
        //4
        if(J>2&&J<13){
            if(board[I][J-2]==0&&board[I][J-1]==1&&board[I][J+1]==1&&board[I][J+2]==1&&board[I][J+3]==0){
                return 1;
            }
        }
        if(I>2&&I<13){
            if(board[I-2][J]==0&&board[I-1][J]==1&&board[I+1][J]==1&&board[I+2][J]==1&&board[I+3][J]==0){
                return 1;
            }
        }
        if(I>2&&I<13&&J>2&&J<13){
            if(board[I-2][J-2]==0&&board[I-1][J-1]==1&&board[I+1][J+1]==1&&board[I+2][J+2]==1&&board[I+3][J+3]==0){
                return 1;
            }
        }
        if(I>2&&I<13&&J>3&&J<14){
            if(board[I-2][J+2]==0&&board[I-1][J+1]==1&&board[I+1][J-1]==1&&board[I+2][J-2]==1&&board[I+3][J-3]==0){
                return 1;
            }
        }
        //5
        if(J<11){
            if(board[I][J+1]==1&&board[I][J+2]!=2&&board[I][J+3]!=2&&board[I][J+4]==1&&board[I][J+5]==0&&board[I][J+2]+board[I][J+3]==1){
                return 1;
            }
        }
        if(I<11){
            if(board[I+1][J]==1&&board[I+2][J]!=2&&board[I+3][J]!=2&&board[I+4][J]==1&&board[I+5][J]==0&&board[I+2][J]+board[I+3][J]==1){
                return 1;
            }
        }
        if(I<11&&J<11){
            if(board[I+1][J+1]==1&&board[I+2][J+2]!=2&&board[I+3][J+3]!=2&&board[I+4][J+4]==1&&board[I+5][J+5]==0&&board[I+2][J+2]+board[I+3][J+3]==1){
                return 1;
            }
        }
        if(I<11&&J>5){
            if(board[I+1][J-1]==1&&board[I+2][J-2]!=2&&board[I+3][J-3]!=2&&board[I+4][J-4]==1&&board[I+5][J-5]==0&&board[I+2][J-2]+board[I+3][J-3]==1){
                return 1;
            }
        }
        //6
        if(J>5){
            if(board[I][J-1]==1&&board[I][J-2]!=2&&board[I][J-3]!=2&&board[I][J-4]==1&&board[I][J-5]==0&&board[I][J-2]+board[I][J-3]==1){
                return 1;
            }
        }
        if(I>5){
            if(board[I-1][J]==1&&board[I-2][J]!=2&&board[I-3][J]!=2&&board[I-4][J]==1&&board[I-5][J]==0&&board[I-2][J]+board[I-3][J]==1){
                return 1;
            }
        }
        if(I>5&&J>5){
            if(board[I-1][J-1]==1&&board[I-2][J-2]!=2&&board[I-3][J-3]!=2&&board[I-4][J-4]==1&&board[I-5][J-5]==0&&board[I-2][J-2]+board[I-3][J-3]==1){
                return 1;
            }
        }
        if(I>5&&J<11){
            if(board[I-1][J+1]==1&&board[I-2][J+2]!=2&&board[I-3][J+3]!=2&&board[I-4][J+4]==1&&board[I-5][J+5]==0&&board[I-2][J+2]+board[I-3][J+3]==1){
                return 1;
            }
        }
    }
    else{
        //1
        if(J<12){
            if(board[I][J+1]==1&&board[I][J+2]==1&&board[I][J+3]==1&&board[I][J+4]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
        if(I<12){
            if(board[I+1][J]==1&&board[I+2][J]==1&&board[I+3][J]==1&&board[I+4][J]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
        if(I<12&&J<12){
            if(board[I+1][J+1]==1&&board[I+2][J+2]==1&&board[I+3][J+3]==1&&board[I+4][J+4]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
        if(I<12&&J>4){
            if(board[I+1][J-1]==1&&board[I+2][J-2]==1&&board[I+3][J-3]==1&&board[I+4][J-4]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
        //2
        if(J>4){
            if(board[I][J-1]==1&&board[I][J-2]==1&&board[I][J-3]==1&&board[I][J-4]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
        if(I>4){
            if(board[I-1][J]==1&&board[I-2][J]==1&&board[I-3][J]==1&&board[I-4][J]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
        if(I>4&&J>4){
            if(board[I-1][J-1]==1&&board[I-2][J-2]==1&&board[I-3][J-3]==1&&board[I-4][J-4]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
        if(I>4&&J<12){
            if(board[I-1][J+1]==1&&board[I-2][J+2]==1&&board[I-3][J+3]==1&&board[I-4][J+4]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
        //3
        if(J>3&&J<14){
            if(board[I][J-3]==0&&board[I][J-2]==1&&board[I][J-1]==1&&board[I][J+1]==1&&board[I][J+2]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
        if(I>3&&I<14){
            if(board[I-3][J]==0&&board[I-2][J]==1&&board[I-1][J]==1&&board[I+1][J]==1&&board[I+2][J]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    //cout<<"aaaaaaaaaaaaaaaaaaa"<<I-1<<J-1<<endl;
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
        if(I>3&&I<14&&J>3&&J<14){
            if(board[I-3][J-3]==0&&board[I-2][J-2]==1&&board[I-1][J-1]==1&&board[I+1][J+1]==1&&board[I+2][J+2]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
        if(I>3&&I<14&&J>2&&J<13){
            if(board[I-3][J+3]==0&&board[I-2][J+2]==1&&board[I-1][J+1]==1&&board[I+1][J-1]==1&&board[I+2][J-2]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
        //4
        if(J>2&&J<13){
            if(board[I][J-2]==0&&board[I][J-1]==1&&board[I][J+1]==1&&board[I][J+2]==1&&board[I][J+3]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
        if(I>2&&I<13){
            if(board[I-2][J]==0&&board[I-1][J]==1&&board[I+1][J]==1&&board[I+2][J]==1&&board[I+3][J]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
        if(I>2&&I<13&&J>2&&J<13){
            if(board[I-2][J-2]==0&&board[I-1][J-1]==1&&board[I+1][J+1]==1&&board[I+2][J+2]==1&&board[I+3][J+3]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
        if(I>2&&I<13&&J>3&&J<14){
            if(board[I-2][J+2]==0&&board[I-1][J+1]==1&&board[I+1][J-1]==1&&board[I+2][J-2]==1&&board[I+3][J-3]==0){
                board0[I-1][J-1]=1;
                if(!Judge_banner::IsDisallowed(0,board0,I-1,J-1)){
                    board0[I-1][J-1]=0;
                    return 1;
                }
                else board0[I-1][J-1]=0;
            }
        }
    }
    return 0;
}
